package servlet;

import hadoop.HadoopUtil;
import hadoop.Wordcount;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author cheng
 * @date 2022-03-07 22:38
 */
@WebServlet("/demo4")
public class ServletDemo4  extends HttpServlet{

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 获取参数
        String srcPath = req.getParameter("srcPath");
        String destPath = req.getParameter("destPath");

        // hadoop 工具类
        HadoopUtil hadoop =   new HadoopUtil();

        // hdfs 上传文件
        String obj1 = hadoop.hadoopDownload(srcPath,destPath);
        //


        resp.setContentType("text/html;charset=utf-8");
        PrintWriter pw =  resp.getWriter();
        pw.write("<h1>"+  obj1);

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
